﻿using System.Data;
using System.IO;

namespace Gamey
{
    public abstract class GameLoader
    {
        public void LoadGames(DataTable table)
        {
            var romsDirectory = new DirectoryInfo(RomsPath);

            RomReader reader = GetRomReader();
            foreach (FileInfo romFile in romsDirectory.EnumerateFiles("*.zip"))
            {
                DataRow row = table.NewRow();
                row.SetField("File", romFile.Name);

                reader.PopulateRowFromZipFile(row, romFile.FullName);

                table.Rows.Add(row);
            }
        }

        protected abstract string RomsPath { get; }

        protected abstract RomReader GetRomReader();
    }
}
